<!-- 模板 -->
<template>
  <div class="" v-if="newsArr.length > 0">News:{{ newsArr[this.$route.params.id - 1].title }}</div>
</template>

<script>
export default {
  name: '',
  data() {
    return {
      newsArr: []
    }
  },
  methods: {
    async getNewsList() {
      let { data: newsArr } = await this.axios.get('https://web17.oss-cn-hangzhou.aliyuncs.com/news.json')
      this.newsArr = newsArr
    }
  },
  created() {
    //使用axios请求数据加载到data中
    this.getNewsList()
  },
  mounted() {
    console.log(this.$route)
  }
}
</script>

<style lang="less" scoped>
//@import url(); 引入公共css类
</style>
